<template>
	<view class="article_list">
		<list-components :data="articlelist" @clickItem="getDetail"></list-components>
	</view>
</template>

<script>
	export default {



		data() {
			return {
				list1: [],
				articlelist: [],
				page: 0,
				page_size: 10,
				current: 0,
				cid:0
			}
		},
		methods: {

			getData() {
				console.log(this.page + ":" + this.page_size);
				// + '&page_size=' + this.page_size
				this.$u.get('/article/list/0/json?cid=' +this.cid +'&page=' + this.page+ '&page_size=' + this.page_size).then((res) => {
					this.articlelist = [...this.articlelist, ...res.data.datas]
					console.log('成功');
				}).catch((res) => {
					console.log('失败');
				})

			},
			getDetail(data) {
				console.log(data.link);
				uni.navigateTo({
					url: '../webview/webview?url=' + data.link
				})
			},
			change() {

			}
		},
		onLoad: function(option) {
			this.cid= option.cid;
			this.getData();
		},
		onPullDownRefresh() {
			console.log('触发下拉刷新')
			this.page = 0;
			this.page_size = 10;
			this.articlelist = [];
			this.getData();
			setTimeout(function() {
				uni.stopPullDownRefresh();
			}, 1000);
		},
		onReachBottom() {
			this.page++;
			// this.page_size = this.page_size + 10;
			this.getData();
		}

	}
</script>

<style>
	.article_list {}
</style>
